<template>
  <view class="product-card">
    <image 
      class="product-cover" 
      :src="product.cover" 
      mode="aspectFill"
      lazy-load
    />
    <view class="product-info">
      <text class="product-name">{{product.name}}</text>
      <text class="product-desc">{{product.desc}}</text>
      <view class="price-container">
        <text class="product-price">¥{{product.price}}</text>
        <text class="product-sales">销量: {{product.sales}}</text>
      </view>
    </view>
  </view>
</template>

<script setup>
defineProps({
  product: {
    type: Object,
    required: true,
    default: () => ({
      id: 0,
      cover: '',
      name: '',
      desc: '',
      price: 0,
      sales: 0
    })
  }
})
</script>

<style lang="scss">
.product-card {
  background-color: $white-bg;;
  border-radius: 10rpx;
  overflow: hidden;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  
  .product-cover {
    width: 100%;
    height: 300rpx;
    display: block;
  }
  
  .product-info {
    padding: 20rpx;
    
    .product-name {
      font-size: $font-size-28rpx;
      color: $text-color;
      font-weight: bold;
      display: block;
      margin-bottom: 10rpx;
      @include text-ellipsis(2);
    }
    
    .product-desc {
      font-size: 24rpx;
      color: #999;
      display: block;
      margin-bottom: 15rpx;
      @include text-ellipsis(1);
    }
    
    .price-container {
      display: flex;
      justify-content: space-between;
      align-items: center;
      
      .product-price {
        font-size: $font-size-30rpx;
        color: $primary-color;
        font-weight: bold;
      }
      
      .product-sales {
        font-size: 22rpx;
        color: #999;
      }
    }
  }
}
</style>